// 装饰器模式

package decorator

import "fmt"

// 定义接口画家
type Painter interface {
	DrawCircle()
	DrawRectangle()
}

// 实现一个画家
type PainterA struct {
	Painter
}

type PainterDecorator struct {
	A PainterA // 本身持有一个画家A
	Painter
}

func (p *PainterA) DrawCircle() {
	fmt.Println("PainterA DrawCircle")
}

func (p *PainterA) DrawRectangle() {
	fmt.Println("PainterA DrawRectangle")
}

func (p *PainterDecorator) DrawCircle() {
	fmt.Println("Use red color") // 增加能力
	p.A.DrawCircle()
}

func (p *PainterDecorator) DrawRectangle() {
	fmt.Println("Use red color") // 增加能力
	p.A.DrawRectangle()
}

/*
func main() {
	// 使用原始画家可以进行操作
	painter := &PainterA{}
	painter.DrawCircle()
	painter.DrawRectangle()
	// 使用装饰器加强了画家，做同样的操作
	painter1 := &PainterDecorator{
		A: PainterA{},
	}
	painter1.DrawCircle()
	painter1.DrawRectangle()
}
*/
